package cn.fl.hsj.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.hsj.service.IHsjQueryService;
import tc.relationmap.facade.relationmap.hsj.api.IHsjBasicApiService;
import tc.relationmap.facade.relationmap.hsj.dto.HsjBasicDTO;
import tc.relationmap.facade.relationmap.hsj.dto.HsjPersonDTO;
import tc.relationmap.facade.relationmap.hsj.dto.HsjShareHolderDTO;
@Service
public class HsjQueryServiceImpl implements IHsjQueryService {

	@Autowired
	private IHsjBasicApiService hsjBasicApiService ;
	@Override
	public HsjBasicDTO getCommInfoByNameAndType(String selectType, String selectValue) throws BaseException {
		// TODO Auto-generated method stub
		if(StringUtils.isEmpty(selectType)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001, BaseExceptionConstant.COMMON_0001_NAME,"查询类型为空！");
		}
		if(StringUtils.isEmpty(selectValue)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001, BaseExceptionConstant.COMMON_0001_NAME,"查询值为空！");
		}
		return hsjBasicApiService.getCommInfoByNameAndType(selectType, selectValue);
	}
	@Override
	public List<HsjPersonDTO> searchPersonDTOListByName(String name) throws BaseException {
		// TODO Auto-generated method stub
		if(StringUtils.isEmpty(name)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001, BaseExceptionConstant.COMMON_0001_NAME,"查询值为空！");
		}
		return this.hsjBasicApiService.searchPersonDTOListByName(name);
	}
	@Override
	public List<HsjShareHolderDTO> searchShareHolderByName(String name) throws BaseException {
		// TODO Auto-generated method stub
		if(StringUtils.isEmpty(name)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001, BaseExceptionConstant.COMMON_0001_NAME,"查询值为空！");
		}
		return this.hsjBasicApiService.searchShareHolderByName(name);
	}

	@Override
	public HsjBasicDTO getCommInfoByNameAndTypeOnTime(String selectType, String selectValue, Date time, String source) throws BaseException {
		if(StringUtils.isEmpty(selectType)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001, BaseExceptionConstant.COMMON_0001_NAME,"查询类型为空！");
		}
		if(StringUtils.isEmpty(selectValue)){
			throw new BaseException(BaseExceptionConstant.COMMON_0001, BaseExceptionConstant.COMMON_0001_NAME,"查询值为空！");
		}
		return hsjBasicApiService.getCommInfoByNameAndTypeOnTime(selectType, selectValue, time, source);
	}

}
